package com.yanqu.road.server.cmd.activity.horserun;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.HorseRunProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.horserun.HorseRunActivityModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_HORSE_RUN_GET_OTHER_HORSE_DATA,desc = "小马快跑获取其他小马数据")
public class HorseRunGetOtherHorseDataCmd extends AbstractCommand {

    private HorseRunProto.HorseRunGetOtherHorseDataReq req;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        req = HorseRunProto.HorseRunGetOtherHorseDataReq.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(HorseRunActivityModule.class).getOtherHorseData(req);
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0){
            HorseRunProto.HorseRunGetOtherHorseDataResp.Builder builder = HorseRunProto.HorseRunGetOtherHorseDataResp.newBuilder();
            builder.setRet(ret);
            player.sendPacket(ClientProtocol.U_HORSE_RUN_GET_OTHER_HORSE_DATA,builder);
        }
    }
}
